#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QLabel>
#include <QTextEdit>
#include <QLineEdit>
#include <QTimer>
#include <QComboBox>
#include <QPushButton>
#include <QKeyEvent>
#include <QString>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE



class QShell : public QTextEdit
{
    Q_OBJECT
public:
    QShell();
    QShell(QWidget *parent = 0){setParent(parent);};

    void setSerial(QSerialPort *s){serial = s;};

protected:
    virtual void keyPressEvent(QKeyEvent *event);

private:
    QSerialPort *serial;
};


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void init(void);

    void serialInit(void);

public slots:
    void update(void);

    void connec_serial(void);

signals:


private:
    Ui::MainWindow *ui;

    QComboBox *serialList;
    QLineEdit *serialBuadrate;

    QPushButton *serialConnect;

    QShell *shell;
    QSerialPort *serial;
    QTimer  *timer;



};
#endif // MAINWINDOW_H
